package com.room.mapper;

import com.room.pojo.NodisClass;
import com.room.pojo.Student;
import com.room.pojo.vo.StudentVO;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;

public interface StudentMapper {
    int deleteByPrimaryKey(Integer studnetId);

    int insert(Student record);

    int insertSelective(Student record);

    Student selectByPrimaryKey(Integer studnetId);

    int updateByPrimaryKeySelective(Student record);

    int updateByPrimaryKey(Student record);

    @Select(  "SELECT "
            +"s.studnet_id as studentId"
            +" FROM"
            +" student s"
            +" WEHRE s.student_no = #{stuNo}")
    String getStuIdByNo(String stuNo);

   List<Student> find(Map map);

    int update(Student student);

    //按专业统计每个班级的男女人数（专业id,专业名，班级id,班级名，班级男生人数，班级女生人数）
    List<NodisClass> findByNodis(String collegeId,String grade);

    List<Student> getStudentByPage(@Param("start")Integer start,@Param("size")Integer size);

    Long getStudnetCount();

    int deleteStuById(@Param("ids")String[] ids);

    int updateStu(@Param("stu")Student student);

    //获取所有学生的数据，导入导出的时候会用到
    List<Student> getAllStudent();

    //将集合中的学生添加到学生表中
    int addStus(@Param("stus")List<Student> stus);


    @Select({
            "SELECT "
            +"s.student_name as studentName,"
            +"s.sex,"
            +"s.class_name as className,"
            +"s.status ,"
            +"s.bedroom_name as bedroomName,"
            +"s.student_no as studentNo,"
            +"s.grade,"
            +"s.college_name as collegeName"
            +" FROM"
            +" student s"
    })
    List<StudentVO> getAllStudentVO();



    int updateStudent();

    //获取最大学号
    public String getMaxId();


    public String getStuNoById(String stuId);

    //通过学号获取到学生
    @Select("select studnet_id as studnetId , student_name as studentName , sex as sex , class_name as className , bedroom_id as bedroomId ,student_no studentNo , grade as grade , college_name as collegeName from student where student_no = #{studentNo}")
    public Student getStudentByNo(@Param("studentNo") String studentNo);

    //根据学院编号获取学生数据
   List<Student> getStudenrByCollegeName(@Param("collegeId") String collegeId);

    //获取某学院学生的总人数
    @Select("select count(*) from student where college_id = #{collegeId}")
    long getTotal(@Param("collegeId") String collegeId);
}